package 哈希;

import java.util.*;

public class 两数之和 {
    /**
     * https://leetcode.cn/problems/two-sum/?envType=study-plan-v2&envId=top-100-liked
     */
    public static int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer> mp =new HashMap<>();
        for(int i=0;i<nums.length;i++){
            mp.put(nums[i],i);
        }

        for(int i=0;i<nums.length;i++){
            if(mp.containsKey(target-nums[i])){
                if(mp.get(target-nums[i])!=i){
                    return new int[]{i,mp.get(target-nums[i])};
                }
            }
        }
        return null;
    }


    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=new String();

    }


}




